package com.ccp.dev.qbdms.controller;

import com.alibaba.fastjson.JSON;
import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.base.BaseController;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.qbdms.model.vo.ModelQualityStatisticsParamVo;
import com.ccp.dev.qbdms.service.MilitaryTradeQualityService;
import com.ccp.dev.system.service.DictionaryService;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassDescribe:
 *
 * @author :milihao
 * @date :2019-07-22 Since:1
 */
@Controller
@Action(customModel = "军贸质量问题统计")
@RequestMapping("/qbdms/militaryTradeQuality")
public class MilitaryTradeQualityController extends BaseController {

	@Resource
	private MilitaryTradeQualityService militaryTradeQualityService;
	@Resource
	private DictionaryService dictionaryService;

	/**
	 * 功能描述: 跳转到军贸质量问题统计首页
	 *
	 * @return: java.lang.String
	 * @auther: mlh
	 * @date: 2020-07-22 09:12:57
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/index")
	@Action(description = "跳转到军贸质量问题统计首页", exectype = "页面跳转日志")
	public String index(ModelMap modelMap) {
		modelMap.put("beginTime", (Calendar.getInstance().get(Calendar.YEAR)) + "-01");
		modelMap.put("endTime", new SimpleDateFormat("yyyy-MM").format(new Date()));
		modelMap.put("tjgz", JSON.toJSONString(dictionaryService.getByNodeKey("ndydtj")));
		return "militaryTradeQuality/index";
	}

	/**
	 * 功能描述: 获取所有统计图数据
	 *
	 * @param: WQbdReportTemplate 实体
	 * @return: java.lang.Object
	 * @auther: milihao
	 * @date: 2020-07-22 15:26:43
	 */
	@RequestMapping("/getChartData")
	@ResponseBody
	@Action(description = "获取统计图数据", detail = "获取所有统计图数据<#if success>成功<#else>失败</#if>")
	public Object getCharData(ModelQualityStatisticsParamVo modelQualityStatisticsParamVo,HttpServletRequest request) {
		QueryFilter queryFilter = new QueryFilter(request, false);
		List<Map<String, Object>> dataMapList = militaryTradeQualityService
				.getChartData(modelQualityStatisticsParamVo,queryFilter);
		SysAuditThreadLocalHolder.putParamerter("success", true);
		return success(dataMapList);
	}

	/**
	 * 功能描述: 跳转到型号质量列表页
	 *
	 * @return: java.lang.String
	 * @auther: mlh
	 * @date: 2020-07-22 09:12:57
	 */
	@RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/list")
	@Action(description = "跳转到型号质量列表页", exectype = "页面跳转日志")
	public String list(ModelMap modelMap, HttpServletRequest request) {
		modelMap.put("title", RequestUtil.getString(request, "title"));
		modelMap.put("tjgz", RequestUtil.getString(request, "tjgz"));
		modelMap.put("beginTime", RequestUtil.getString(request, "beginTime"));
		modelMap.put("endTime", RequestUtil.getString(request, "endTime"));
		modelMap.put("isOther", RequestUtil.getString(request, "isOther"));
		return "militaryTradeQuality/list";
	}
}
